package com.yusheng.controller;

import com.google.gson.Gson;
import com.yusheng.dao.QueryAppproval;
import com.yusheng.entity.ApprovalRecordList;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

public class ShowApproval extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取参数，就是当前的记录名
        System.out.println("ShowApproval执行：主要获取审批表，并且返回");
        String recordNo=request.getParameter("recordno");
        //获取这个审批，以及之前的审批
        ApprovalRecordList approvalRecordList= QueryAppproval.getApprovalsByRecordNo(recordNo);
        //写到请求会话作用域中
        Gson gson=new Gson();
        String s=gson.toJson(approvalRecordList);
        request.setAttribute("approvalList",s);
        //请求转发到Approval.jsp.
        request.getRequestDispatcher("Approval.jsp").forward(request,response);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
